Add lint for common testharness.js mistakes and clean up tests that make those mistakes.
diff --git a/.travis.yml b/.travis.yml index 46e2eaa..78b01a5 100644 --- a/.travis.yml +++ b/.travis.yml
@@ -2,6 +2,6 @@ python: - "2.7" # command to install dependencies, e.g. pip install -r requirements.txt --use-mirrors -# install: pip install lxml +install: pip install html5lib # command to run tests, e.g. python setup.py test script: python tools/scripts/lint.py \ No newline at end of file
diff --git a/XMLHttpRequest/abort-event-abort.htm b/XMLHttpRequest/abort-event-abort.htm index b71ea14..79f1cfd 100644 --- a/XMLHttpRequest/abort-event-abort.htm +++ b/XMLHttpRequest/abort-event-abort.htm
@@ -3,6 +3,7 @@ <head> <link rel="help" href="http://dvcs.w3.org/hg/xhr/raw-file/tip/Overview.html#the-abort()-method" data-tested-assertations="following-sibling::ol/li[4]/ol/li[5]" /> <script src="/resources/testharness.js"></script> + <script src="/resources/testharnessreport.js"></script> <title>XMLHttpRequest: The abort() method: do not fire abort event in OPENED state when send() flag is unset. send() throws after abort().</title> </head>
diff --git a/XMLHttpRequest/abort-event-loadend.htm b/XMLHttpRequest/abort-event-loadend.htm index c72229b..23786ac 100644 --- a/XMLHttpRequest/abort-event-loadend.htm +++ b/XMLHttpRequest/abort-event-loadend.htm
@@ -3,6 +3,7 @@ <head> <link rel="help" href="http://dvcs.w3.org/hg/xhr/raw-file/tip/Overview.html#the-abort()-method" data-tested-assertations="following-sibling::ol/li[4]/ol/li[6]"/> <script src="/resources/testharness.js"></script> + <script src="/resources/testharnessreport.js"></script> <title>XMLHttpRequest: The abort() method: Fire a progress event named loadend</title> </head>
diff --git a/XMLHttpRequest/abort-event-order.htm b/XMLHttpRequest/abort-event-order.htm index 8e1f767..1882e14 100644 --- a/XMLHttpRequest/abort-event-order.htm +++ b/XMLHttpRequest/abort-event-order.htm
@@ -3,6 +3,7 @@ <head> <link rel="help" href="http://dvcs.w3.org/hg/xhr/raw-file/tip/Overview.html#the-abort()-method" data-tested-assertations="following-sibling::ol/li[4]/ol/li[3] following-sibling::ol/li[4]/ol/li[5] following-sibling::ol/li[4]/ol/li[6] following-sibling::ol/li[4]/ol/li[7]/ol/li[3] following-sibling::ol/li[4]/ol/li[7]/ol/li[4] following-sibling::ol/li[5]" /> <script src="/resources/testharness.js"></script> + <script src="/resources/testharnessreport.js"></script> <title>XMLHttpRequest: The abort() method: abort and loadend events</title> </head>
diff --git a/XMLHttpRequest/abort-upload-event-abort.htm b/XMLHttpRequest/abort-upload-event-abort.htm index e63dcca..8590d61 100644 --- a/XMLHttpRequest/abort-upload-event-abort.htm +++ b/XMLHttpRequest/abort-upload-event-abort.htm
@@ -3,6 +3,7 @@ <head> <link rel="help" href="http://dvcs.w3.org/hg/xhr/raw-file/tip/Overview.html#the-abort()-method" data-tested-assertations="following-sibling::ol/li[4]/ol/li[7]/ol/li[3]" /> <script src="/resources/testharness.js"></script> + <script src="/resources/testharnessreport.js"></script> <title>XMLHttpRequest: The abort() method: Fire a progress event named abort on the XMLHttpRequestUpload object</title> </head> @@ -29,7 +30,7 @@ xhr.upload.onabort = function(e) { - test.step(function() + test.step(function() { assert_true(e instanceof ProgressEvent); assert_equals(e.type, "abort"); diff --git a/XMLHttpRequest/abort-upload-event-loadend.htm b/XMLHttpRequest/abort-upload-event-loadend.htm index d29d477..524f71e 100644 --- a/XMLHttpRequest/abort-upload-event-loadend.htm +++ b/XMLHttpRequest/abort-upload-event-loadend.htm
@@ -3,6 +3,7 @@ <head> <link rel="help" href="http://dvcs.w3.org/hg/xhr/raw-file/tip/Overview.html#the-abort()-method" data-tested-assertations="following-sibling::ol/li[4]/ol/li[7]/ol/li[4]" /> <script src="/resources/testharness.js"></script> + <script src="/resources/testharnessreport.js"></script> <title>XMLHttpRequest: The abort() method: Fire a progress event named loadend on the XMLHttpRequestUpload object</title> </head>
diff --git a/XMLHttpRequest/response-data-arraybuffer.htm b/XMLHttpRequest/response-data-arraybuffer.htm index 2261605..83cf165 100644 --- a/XMLHttpRequest/response-data-arraybuffer.htm +++ b/XMLHttpRequest/response-data-arraybuffer.htm
@@ -4,6 +4,7 @@ <link rel="help" href="http://dvcs.w3.org/hg/xhr/raw-file/tip/Overview.html#the-responsetype-attribute" data-tested-assertations="following::ol[1]/li[4]" /> <link rel="help" href="http://dvcs.w3.org/hg/xhr/raw-file/tip/Overview.html#the-response-attribute" data-tested-assertations="following::a[contains(@href,'#arraybuffer-response-entity-body')]/.." /> <script src="/resources/testharness.js"></script> + <script src="/resources/testharnessreport.js"></script> <title>XMLHttpRequest: The response attribute: ArrayBuffer data</title> </head>
diff --git a/XMLHttpRequest/response-data-blob.htm b/XMLHttpRequest/response-data-blob.htm index c9b3fbb..347bf99 100644 --- a/XMLHttpRequest/response-data-blob.htm +++ b/XMLHttpRequest/response-data-blob.htm
@@ -5,6 +5,7 @@ <link rel="help" href="http://dvcs.w3.org/hg/xhr/raw-file/tip/Overview.html#the-responsetype-attribute" data-tested-assertations="following::ol[1]/li[4]"/> <link rel="help" href="http://dvcs.w3.org/hg/xhr/raw-file/tip/Overview.html#the-response-attribute" data-tested-assertations="following::a[contains(@href,'#blob-response-entity-body')]/.." /> <script src="/resources/testharness.js"></script> + <script src="/resources/testharnessreport.js"></script> <title>XMLHttpRequest: The response attribute: Blob data</title> </head>
diff --git a/XMLHttpRequest/send-data-arraybuffer.htm b/XMLHttpRequest/send-data-arraybuffer.htm index 62139ad..4a3d461 100644 --- a/XMLHttpRequest/send-data-arraybuffer.htm +++ b/XMLHttpRequest/send-data-arraybuffer.htm
@@ -5,6 +5,7 @@ <link rel="help" href="http://dvcs.w3.org/hg/xhr/raw-file/tip/Overview.html#the-status-attribute" data-tested-assertations="following::ol[1]/li[3]"/> <link rel="help" href="http://dvcs.w3.org/hg/xhr/raw-file/tip/Overview.html#the-response-attribute" data-tested-assertations="following::ol[1]/li[3]"/> <script src="/resources/testharness.js"></script> + <script src="/resources/testharnessreport.js"></script> <title>XMLHttpRequest: The send() method: ArrayBuffer data</title> </head> @@ -27,7 +28,7 @@ xhr.onreadystatechange = function() { - if (xhr.readyState == 4) + if (xhr.readyState == 4) { test.step(function() { diff --git a/XMLHttpRequest/send-data-blob.htm b/XMLHttpRequest/send-data-blob.htm index 7160429..1e394d7 100644 --- a/XMLHttpRequest/send-data-blob.htm +++ b/XMLHttpRequest/send-data-blob.htm
@@ -7,6 +7,7 @@ <link rel="help" href="http://dvcs.w3.org/hg/xhr/raw-file/tip/Overview.html#the-response-attribute" data-tested-assertations="following::a[contains(@href,'#blob-response-entity-body')]/.."/> <script src="/resources/testharness.js"></script> + <script src="/resources/testharnessreport.js"></script> <title>XMLHttpRequest: The send() method: Blob data</title> </head> @@ -20,7 +21,7 @@ { var xhr = new XMLHttpRequest(); var xhr2 = new XMLHttpRequest(); - + var content = "Hello"; var blob; @@ -32,7 +33,7 @@ { blob = xhr.response; assert_true(blob instanceof Blob, "Blob from XHR Response"); - + xhr2.open("POST", "./resources/content.py", true); xhr2.send(blob); }); @@ -51,7 +52,7 @@ }); } }; - + xhr.open("GET", "./resources/content.py?content=" + content, true); xhr.responseType = "blob"; xhr.send(); diff --git a/XMLHttpRequest/send-data-formdata.htm b/XMLHttpRequest/send-data-formdata.htm index 3d87eb6..1a64b0a 100644 --- a/XMLHttpRequest/send-data-formdata.htm +++ b/XMLHttpRequest/send-data-formdata.htm
@@ -5,6 +5,7 @@ <link rel="help" href="http://dvcs.w3.org/hg/xhr/raw-file/tip/Overview.html#interface-formdata" data-tested-assertations="following::*[contains(@id,'dom-formdata')]/following::ol[1]/li[1] following::*[contains(@id,'dom-formdata')]/following::ol[1]/li[3] following::*[contains(@id,'dom-formdata-append')]/following::ul[1]/li[1] following::*[contains(@id,'dom-formdata-append')]/following::ul[1]/li[2]" /> <link rel="help" href="http://dvcs.w3.org/hg/xhr/raw-file/tip/Overview.html#the-response-attribute" data-tested-assertations="following::ol[1]/li[3]"/> <script src="/resources/testharness.js"></script> + <script src="/resources/testharnessreport.js"></script> <title>XmlHttpRequest: The send() method: FormData data</title> </head> @@ -14,18 +15,18 @@ <script type="text/javascript"> var test = async_test(); - test.step(function() + test.step(function() { var xhr = new XMLHttpRequest(); var form = new FormData(); form.append("id", "0"); form.append("value", "zero"); - xhr.onreadystatechange = function() + xhr.onreadystatechange = function() { - test.step(function () + test.step(function () { - if (xhr.readyState == 4) + if (xhr.readyState == 4) { assert_equals(xhr.status, 200); assert_equals(xhr.response, "id:0;value:zero;"); diff --git a/XMLHttpRequest/send-network-error-async-events.sub.htm b/XMLHttpRequest/send-network-error-async-events.sub.htm index ebbebda..d44fdd8 100644 --- a/XMLHttpRequest/send-network-error-async-events.sub.htm +++ b/XMLHttpRequest/send-network-error-async-events.sub.htm
@@ -7,6 +7,7 @@ <link rel="help" href="http://dvcs.w3.org/hg/xhr/raw-file/tip/Overview.html#network-error" data-tested-assertations=".." /> <link rel="help" href="http://dvcs.w3.org/hg/xhr/raw-file/tip/Overview.html#request-error" data-tested-assertations="following::ol[1]/li[4] following::ol[1]/li[6] following::ol[1]/li[7] following::ol[1]/li[7]/ol/li[3] following::ol[1]/li[7]/ol/li[4] following::ol[1]/li[9] following::ol[1]/li[10]" /> <script src="/resources/testharness.js"></script> + <script src="/resources/testharnessreport.js"></script> <title>XmlHttpRequest: The send() method: Fire a progress event named error when Network error happens (synchronous flag is unset)</title> </head> @@ -35,7 +36,7 @@ xhr.onloadstart = function(e){ actual.push(e.type); }; xhr.onloadend = function(e){ actual.push(e.type); VerifyResult()}; xhr.onerror = function(e){ actual.push(e.type); }; - + xhr.upload.onloadstart = function(e){ actual.push("upload." + e.type);}; xhr.upload.onloadend = function(e){ actual.push("upload." + e.type);}; xhr.upload.onerror = function(e){ actual.push("upload." + e.type); }; diff --git a/XMLHttpRequest/send-network-error-sync-events.sub.htm b/XMLHttpRequest/send-network-error-sync-events.sub.htm index 161a39a..d985344 100644 --- a/XMLHttpRequest/send-network-error-sync-events.sub.htm +++ b/XMLHttpRequest/send-network-error-sync-events.sub.htm
@@ -5,6 +5,7 @@ <link rel="help" href="http://dvcs.w3.org/hg/xhr/raw-file/tip/Overview.html#network-error" data-tested-assertations=".." /> <link rel="help" href="http://dvcs.w3.org/hg/xhr/raw-file/tip/Overview.html#request-error" data-tested-assertations="following::ol[1]/li[4] following::ol[1]/li[5]" /> <script src="/resources/testharness.js"></script> + <script src="/resources/testharnessreport.js"></script> <title>XmlHttpRequest: The send() method: Throw a "throw an "NetworkError" exception when Network error happens (synchronous flag is set)</title> </head>
diff --git a/XMLHttpRequest/send-no-response-event-loadend.htm b/XMLHttpRequest/send-no-response-event-loadend.htm index e8f9efe..cd8406d 100644 --- a/XMLHttpRequest/send-no-response-event-loadend.htm +++ b/XMLHttpRequest/send-no-response-event-loadend.htm
@@ -2,6 +2,7 @@ <html> <head> <script src="/resources/testharness.js"></script> + <script src="/resources/testharnessreport.js"></script> <title>XMLHttpRequest: The send() method: Fire a progress event named loadend (no response entity body)</title> <link rel="help" href="http://dvcs.w3.org/hg/xhr/raw-file/tip/Overview.html#handler-xhr-onloadend" data-tested-assertations="/../.." /> <link rel="help" href="http://dvcs.w3.org/hg/xhr/raw-file/tip/Overview.html#event-xhr-loadend" data-tested-assertations="/../.." /> @@ -10,7 +11,7 @@ <body> <div id="log"></div> - + <script type="text/javascript"> var test = async_test();
diff --git a/XMLHttpRequest/send-no-response-event-loadstart.htm b/XMLHttpRequest/send-no-response-event-loadstart.htm index ff5d5fb..5183f7a 100644 --- a/XMLHttpRequest/send-no-response-event-loadstart.htm +++ b/XMLHttpRequest/send-no-response-event-loadstart.htm
@@ -6,12 +6,13 @@ <link rel="help" href="http://dvcs.w3.org/hg/xhr/raw-file/tip/Overview.html#the-send()-method" data-tested-assertations="/following-sibling::ol/li[9]/ol/li[2]" /> <link rel="help" href="http://dvcs.w3.org/hg/xhr/raw-file/tip/Overview.html#the-response-attribute" data-tested-assertations="/following-sibling::ol/li[1]" /> <script src="/resources/testharness.js"></script> + <script src="/resources/testharnessreport.js"></script> <title>XMLHttpRequest: The send() method: Fire a progress event named loadstart (no response entity body and the state is LOADING)</title> </head> <body> <div id="log"></div> - + <script type="text/javascript"> var test = async_test();
diff --git a/XMLHttpRequest/send-no-response-event-order.htm b/XMLHttpRequest/send-no-response-event-order.htm index 35c9d16..f8d800f 100644 --- a/XMLHttpRequest/send-no-response-event-order.htm +++ b/XMLHttpRequest/send-no-response-event-order.htm
@@ -10,12 +10,13 @@ <link rel="help" href="http://dvcs.w3.org/hg/xhr/raw-file/tip/Overview.html#switch-done" data-tested-assertations="following::ol[1]/li[3] following::ol[1]/li[4] following::ol[1]/li[6] following::ol[1]/li[7]" /> <link rel="help" href="http://dvcs.w3.org/hg/xhr/raw-file/tip/Overview.html#the-response-attribute" data-tested-assertations="following-sibling::ol/li[1]" /> <script src="/resources/testharness.js"></script> + <script src="/resources/testharnessreport.js"></script> <title>XMLHttpRequest: The send() method: event order when there is no response entity body</title> </head> <body> <div id="log"></div> - + <script type="text/javascript"> var test = async_test(); @@ -29,21 +30,21 @@ { test.step(function() { - if (xhr.readyState == 3) + if (xhr.readyState == 3) { assert_equals(xhr.response, ""); } - else if (xhr.readyState == 4) + else if (xhr.readyState == 4) { actual.push(xhr.readyState); } }); }; - + xhr.onloadstart = function(e){ actual.push(e.type); }; xhr.onload = function(e){ actual.push(e.type); }; xhr.onloadend = function(e){ actual.push(e.type); VerifyResult()}; - + xhr.upload.onloadstart = function(e){ assert_unreached('upload.'+e.type); }; xhr.upload.onload = function(e){ assert_unreached('upload.'+e.type); }; xhr.upload.onloadend = function(e){ assert_unreached('upload.'+e.type); }; diff --git a/XMLHttpRequest/send-response-event-order.htm b/XMLHttpRequest/send-response-event-order.htm index 85d25cc..e466c6f 100644 --- a/XMLHttpRequest/send-response-event-order.htm +++ b/XMLHttpRequest/send-response-event-order.htm
@@ -11,6 +11,7 @@ <link rel="help" href="http://dvcs.w3.org/hg/xhr/raw-file/tip/Overview.html#infrastructure-for-the-send()-method" data-tested-assertations="following::a[contains(@href,'#switch-done')]/.." /> <link rel="help" href="http://dvcs.w3.org/hg/xhr/raw-file/tip/Overview.html#switch-done" data-tested-assertations="following::ol[1]/li[3] following::ol[1]/li[4] following::ol[1]/li[5] following::ol[1]/li[6] following::ol[1]/li[7]" /> <script src="/resources/testharness.js"></script> + <script src="/resources/testharnessreport.js"></script> <title>XMLHttpRequest: The send() method: event order when synchronous flag is unset</title> </head>
diff --git a/XMLHttpRequest/send-response-upload-event-loadend.htm b/XMLHttpRequest/send-response-upload-event-loadend.htm index 1fff82b..cf0ca82 100644 --- a/XMLHttpRequest/send-response-upload-event-loadend.htm +++ b/XMLHttpRequest/send-response-upload-event-loadend.htm
@@ -7,6 +7,7 @@ <link rel="help" href="http://dvcs.w3.org/hg/xhr/raw-file/tip/Overview.html#make-upload-progress-notifications" data-tested-assertations="following::ul[1]/li[2]/ol[1]/li[4]" /> <script src="/resources/testharness.js"></script> + <script src="/resources/testharnessreport.js"></script> <title>XMLHttpRequest: The send() method: Fire a progress event named loadend on the XMLHttpRequestUpload (synchronous flag is unset)</title> </head>
diff --git a/XMLHttpRequest/send-response-upload-event-loadstart.htm b/XMLHttpRequest/send-response-upload-event-loadstart.htm index 0160df7..ae83e71 100644 --- a/XMLHttpRequest/send-response-upload-event-loadstart.htm +++ b/XMLHttpRequest/send-response-upload-event-loadstart.htm
@@ -6,6 +6,7 @@ <link rel="help" href="http://dvcs.w3.org/hg/xhr/raw-file/tip/Overview.html#the-send()-method" data-tested-assertations="following::ol[1]/li[8] following-sibling::ol/li[9]/ol/li[3]" /> <script src="/resources/testharness.js"></script> + <script src="/resources/testharnessreport.js"></script> <title>XMLHttpRequest: The send() method: Fire a progress event named loadstart on the XMLHttpRequestUpload (synchronous flag is unset)</title> </head> @@ -15,18 +16,18 @@ <script type="text/javascript"> var test = async_test(); - test.step(function() + test.step(function() { var xhr = new XMLHttpRequest(); - xhr.upload.onloadstart = function(e) + xhr.upload.onloadstart = function(e) { - test.step(function() + test.step(function() { assert_true(e instanceof ProgressEvent); assert_equals(e.type, "loadstart"); assert_equals(e.target, xhr.upload); - test.done(); + test.done(); }); }; diff --git a/XMLHttpRequest/send-response-upload-event-progress.htm b/XMLHttpRequest/send-response-upload-event-progress.htm index 265f400..b48cc41 100644 --- a/XMLHttpRequest/send-response-upload-event-progress.htm +++ b/XMLHttpRequest/send-response-upload-event-progress.htm
@@ -6,6 +6,7 @@ <link rel="help" href="http://dvcs.w3.org/hg/xhr/raw-file/tip/Overview.html#the-send()-method" data-tested-assertations="following::a[contains(@href,'#make-upload-progress-notifications')]/.. following::ol[1]/li[8]" /> <link rel="help" href="http://dvcs.w3.org/hg/xhr/raw-file/tip/Overview.html#make-upload-progress-notifications" data-tested-assertations="following::ul[1]/li[2]/ol[1]/li[2]" /> <script src="/resources/testharness.js"></script> + <script src="/resources/testharnessreport.js"></script> <title>XMLHttpRequest: The send() method: Fire a progress event named progress on the XMLHttpRequestUpload (synchronous flag is unset)</title> </head>
diff --git a/XMLHttpRequest/send-sync-no-response-event-load.htm b/XMLHttpRequest/send-sync-no-response-event-load.htm index 3356e01..77a9940 100644 --- a/XMLHttpRequest/send-sync-no-response-event-load.htm +++ b/XMLHttpRequest/send-sync-no-response-event-load.htm
@@ -7,6 +7,7 @@ <link rel="help" href="http://dvcs.w3.org/hg/xhr/raw-file/tip/Overview.html#switch-done" data-tested-assertations="following::ol/li[1] following::ol/li[6]" /> <link rel="help" href="http://dvcs.w3.org/hg/xhr/raw-file/tip/Overview.html#the-response-attribute" data-tested-assertations="/following::ol/li[3]" /> <script src="/resources/testharness.js"></script> + <script src="/resources/testharnessreport.js"></script> <title>XMLHttpRequest: The send() method: Fire an event named load (no response entity body and the synchronous flag is set)</title> </head>
diff --git a/XMLHttpRequest/send-sync-no-response-event-loadend.htm b/XMLHttpRequest/send-sync-no-response-event-loadend.htm index 76f7523..fad4aba 100644 --- a/XMLHttpRequest/send-sync-no-response-event-loadend.htm +++ b/XMLHttpRequest/send-sync-no-response-event-loadend.htm
@@ -7,6 +7,7 @@ <link rel="help" href="http://dvcs.w3.org/hg/xhr/raw-file/tip/Overview.html#switch-done" data-tested-assertations="following::ol/li[1] following::ol/li[7]" /> <link rel="help" href="http://dvcs.w3.org/hg/xhr/raw-file/tip/Overview.html#the-response-attribute" data-tested-assertations="/following::ol/li[3]" /> <script src="/resources/testharness.js"></script> + <script src="/resources/testharnessreport.js"></script> <title>XMLHttpRequest: The send() method: Fire an event named loadend (no response entity body and the synchronous flag is set)</title> </head> @@ -14,12 +15,12 @@ <div id="log"></div> <script type="text/javascript"> - test(function() + test(function() { var xhr = new XMLHttpRequest(); var pass = false; - xhr.onloadend = function(e) + xhr.onloadend = function(e) { assert_true(e instanceof ProgressEvent); assert_equals(e.type, "loadend"); diff --git a/XMLHttpRequest/send-sync-no-response-event-order.htm b/XMLHttpRequest/send-sync-no-response-event-order.htm index 7ea8063..5601506 100644 --- a/XMLHttpRequest/send-sync-no-response-event-order.htm +++ b/XMLHttpRequest/send-sync-no-response-event-order.htm
@@ -12,6 +12,7 @@ <link rel="help" href="http://dvcs.w3.org/hg/xhr/raw-file/tip/Overview.html#switch-done" data-tested-assertations="following::ol[1]/li[1] following::ol[1]/li[3] following::ol[1]/li[4] following::ol[1]/li[6] following::ol[1]/li[7]" /> <link rel="help" href="http://dvcs.w3.org/hg/xhr/raw-file/tip/Overview.html#the-response-attribute" data-tested-assertations="following::ol/li[3]" /> <script src="/resources/testharness.js"></script> + <script src="/resources/testharnessreport.js"></script> </head> <body> @@ -23,9 +24,9 @@ var expect = [4, "load", "loadend"]; var actual = []; - xhr.onreadystatechange = function() + xhr.onreadystatechange = function() { - if (xhr.readyState == 4) + if (xhr.readyState == 4) { actual.push(xhr.readyState); } diff --git a/XMLHttpRequest/send-sync-response-event-order.htm b/XMLHttpRequest/send-sync-response-event-order.htm index 48599d9..3aa0d7d 100644 --- a/XMLHttpRequest/send-sync-response-event-order.htm +++ b/XMLHttpRequest/send-sync-response-event-order.htm
@@ -2,6 +2,7 @@ <html> <head> <script src="/resources/testharness.js"></script> + <script src="/resources/testharnessreport.js"></script> <title>XMLHttpRequest: The send() method: event order when synchronous flag is set</title> <link rel="help" href="http://dvcs.w3.org/hg/xhr/raw-file/tip/Overview.html#handler-xhr-onloadstart" data-tested-assertations="../.." /> <link rel="help" href="http://dvcs.w3.org/hg/xhr/raw-file/tip/Overview.html#handler-xhr-onloadend" data-tested-assertations="../.." />
diff --git a/XMLHttpRequest/send-timeout-events.htm b/XMLHttpRequest/send-timeout-events.htm index 37832cf..5b96a3e 100644 --- a/XMLHttpRequest/send-timeout-events.htm +++ b/XMLHttpRequest/send-timeout-events.htm
@@ -2,6 +2,7 @@ <html> <head> <script src="/resources/testharness.js"></script> + <script src="/resources/testharnessreport.js"></script> <title>XMLHttpRequest: The send() method: timeout is not 0 </title> <link rel="help" href="http://dvcs.w3.org/hg/xhr/raw-file/tip/Overview.html#the-timeout-attribute" data-tested-assertations="following::ol[1]/li[2]" /> <link rel="help" href="http://dvcs.w3.org/hg/xhr/raw-file/tip/Overview.html#infrastructure-for-the-send()-method" data-tested-assertations="following::dt[5] following::a[contains(@href,'#timeout-error')]/.." /> @@ -34,7 +35,7 @@ xhr.onloadend = function(e){ actual.push(e.type); VerifyResult()}; xhr.ontimeout = function(e){ actual.push(e.type); }; - + xhr.upload.onloadend = function(e){ actual.push("upload." + e.type);}; xhr.upload.ontimeout = function(e){ actual.push("upload." + e.type); }; @@ -46,13 +47,13 @@ test.done(); }); }; - + var content = ""; for (var i = 0; i < 121026; i++) { content += "[" + i + "]"; } - + xhr.open("POST", "./resources/trickle.py", true); xhr.timeout = 1; xhr.send(content); diff --git a/ambient-light/DeviceLight_tests.html b/ambient-light/DeviceLight_tests.html index ee5cf8c..d55b21b 100644 --- a/ambient-light/DeviceLight_tests.html +++ b/ambient-light/DeviceLight_tests.html
@@ -2,8 +2,9 @@ <meta charset=utf8> <meta content="width=device-width, initial-scale=1" name=viewport> <meta> -<title>Light Events Test Suite</title> +<title>Light Events Test Suite</title> <h1>Test Suite for Light Events</h1> <div id="log"></div> <script src="/resources/testharness.js"></script> +<script src="/resources/testharnessreport.js"></script> <script src="DeviceLight_tests.js"></script>
diff --git a/battery-status/battery-created.html b/battery-status/battery-created-manual.html similarity index 95% rename from battery-status/battery-created.html rename to battery-status/battery-created-manual.html index 26b74fb..a833bc5 100644 --- a/battery-status/battery-created.html +++ b/battery-status/battery-created-manual.html
@@ -3,7 +3,7 @@ <head> <title>Battery Status API Test Suite</title> <script src="/resources/testharness.js"></script> - <link rel="stylesheet" href="/resources/testharness.css" media="all"/> + <script src="/resources/testharnessreport.js"></script> </head> <body> <h1>Description</h1>
diff --git a/battery-status/battery-full.html b/battery-status/battery-full-manual.html similarity index 92% rename from battery-status/battery-full.html rename to battery-status/battery-full-manual.html index b8a3c74..3f552a7 100644 --- a/battery-status/battery-full.html +++ b/battery-status/battery-full-manual.html
@@ -3,7 +3,7 @@ <head> <title>Battery Status API Test Suite</title> <script src="/resources/testharness.js"></script> - <link rel="stylesheet" href="/resources/testharness.css" media="all"/> + <script src="/resources/testharnessreport.js"></script> <meta name="flags" content="interact"> </head> <body> @@ -27,19 +27,19 @@ test(function() { assert_true(navigator.battery.charging); }, 'The charging attribute must be set to true if the battery is full (the "otherwise" condition).'); - + test(function() { assert_true(navigator.battery.chargingTime === 0); }, 'The chargingTime attribute must be set to 0.'); - + test(function() { assert_true(navigator.battery.dischargingTime === Infinity); }, 'The dischargingTime attribute must be set to the value positive Infinity (the "otherwise" condition).'); - + test(function() { assert_true(navigator.battery.level === 1.0); }, 'The level attribute must be set to the value 1.0.'); - + })(); </script> </body> diff --git a/battery-status/battery-interface.html b/battery-status/battery-interface.html index b5c13c8..a7f9e74 100644 --- a/battery-status/battery-interface.html +++ b/battery-status/battery-interface.html
@@ -3,7 +3,7 @@ <head> <title>Battery Status API Test Suite</title> <script src="/resources/testharness.js"></script> - <link rel="stylesheet" href="/resources/testharness.css" media="all"/> + <script src="/resources/testharnessreport.js"></script> <script src="battery-interface.js"></script> </head> <body>
diff --git a/conformance-checkers/xhtml/elements/meter/012-novalid.xhtml b/conformance-checkers/xhtml/elements/meter/012-novalid.xhtml index d5f1237..8372b78 100644 --- a/conformance-checkers/xhtml/elements/meter/012-novalid.xhtml +++ b/conformance-checkers/xhtml/elements/meter/012-novalid.xhtml
@@ -3,6 +3,6 @@ <title>invalid meter</title> </head> <body> -<meter min='0.4' optimum='0.3''/> +<meter min='0.4' optimum='0.3'/> </body> </html>
diff --git a/cors/status-async.htm b/cors/status-async.htm index 26376ab..3573ee8 100644 --- a/cors/status-async.htm +++ b/cors/status-async.htm
@@ -2,7 +2,7 @@ <meta charset=utf-8> <title>CORS - status</title> <meta name=author title="Odin Hørthe Omdal" href="mailto:odiho@opera.com"> -<meta name=timeout value=long> +<meta name=timeout content=long> <script src=/resources/testharness.js></script> <script src=/resources/testharnessreport.js></script>
diff --git a/dom/nodes/Document-characterSet-normalization.html b/dom/nodes/Document-characterSet-normalization.html index 1d49d73..67f12e8 100644 --- a/dom/nodes/Document-characterSet-normalization.html +++ b/dom/nodes/Document-characterSet-normalization.html
@@ -1,7 +1,7 @@ <!doctype html> <title>document.characterSet normalization tests</title> <link rel=author title="Aryeh Gregor" href=ayg@aryeh.name> -<meta name=timeout value=long> +<meta name=timeout content=long> <div id=log></div> <script src=/resources/testharness.js></script> <script src=/resources/testharnessreport.js></script>
diff --git a/eventsource/shared-worker/eventsource-constructor-non-same-origin.htm b/eventsource/shared-worker/eventsource-constructor-non-same-origin.htm index a822b02..277fbd4 100644 --- a/eventsource/shared-worker/eventsource-constructor-non-same-origin.htm +++ b/eventsource/shared-worker/eventsource-constructor-non-same-origin.htm
@@ -17,9 +17,9 @@ <html> <head> <title>shared worker - EventSource: constructor (act as if there is a network error)</title> + <meta name=timeout content=long> <script src="/resources/testharness.js"></script> <script src="/resources/testharnessreport.js"></script> - <meta name=timeout value=long> </head> <body> <div id="log"></div>
diff --git a/html/dom/dynamic-markup-insertion/document-write/script_002.html b/html/dom/dynamic-markup-insertion/document-write/script_002.html index 90d05e0..3879d84 100644 --- a/html/dom/dynamic-markup-insertion/document-write/script_002.html +++ b/html/dom/dynamic-markup-insertion/document-write/script_002.html
@@ -1,6 +1,7 @@ <!doctype html> <title>document.write script executed synchronously</title> <script src="/resources/testharness.js"></script> +<script src="/resources/testharnessreport.js"></script> <script> var t = async_test(); var order = [];
diff --git a/html/semantics/scripting-1/the-script-element/script-text.xhtml b/html/semantics/scripting-1/the-script-element/script-text.xhtml index 13ddf85..4ff43a9 100644 --- a/html/semantics/scripting-1/the-script-element/script-text.xhtml +++ b/html/semantics/scripting-1/the-script-element/script-text.xhtml
@@ -24,3 +24,5 @@ assert_equals(script.textContent, '\n7;\n\n var x = "y";\n\n') }, "Getter with CDATA section") </script> +</body> +</html>
diff --git a/page-visibility/test_attributes_exist.html b/page-visibility/test_attributes_exist.html index 8178c66..748161f 100644 --- a/page-visibility/test_attributes_exist.html +++ b/page-visibility/test_attributes_exist.html
@@ -3,8 +3,9 @@ <head> <meta charset="utf-8" /> <title>Page Visibility API Definition</title> - + <script type="text/javascript" src="/resources/testharness.js"></script> + <script src="/resources/testharnessreport.js"></script> <script type="text/javascript" src="resources/pagevistestharness.js"></script> </head> <body> @@ -13,7 +14,7 @@ (but does not validate that their values are correct).</p> <div id="log"></div> - + <script type="text/javascript" > test_feature_exists(); </script>
diff --git a/page-visibility/test_child_document.html b/page-visibility/test_child_document.html index b321592..77ec8f8 100644 --- a/page-visibility/test_child_document.html +++ b/page-visibility/test_child_document.html
@@ -3,10 +3,11 @@ <head> <meta charset="utf-8" /> <title>Page Visibility API Child Document Test</title> - - <script type="text/javascript" src="/resources/testharness.js"></script> + + <script src="/resources/testharness.js"></script> + <script src="/resources/testharnessreport.js"></script> <script type="text/javascript" src="resources/pagevistestharness.js"></script> - + <style type="text/css"> iframe { @@ -14,7 +15,7 @@ height:250px; margin-left:5px; } - + div.docs { position:relative; @@ -25,17 +26,17 @@ padding:3px; } </style> - + <script type="text/javascript" > setup({explicit_done: true}); - + function onload_test() { pv_test(); - + var frames = document.getElementsByTagName("iframe"); var doc, doc_name; - + for (var i = 0; i < frames.length; i++) { doc = frames[i].contentDocument; @@ -51,20 +52,20 @@ frames[i].id + " == " + VISIBILITY_STATES.VISIBLE); } - + done(); } </script> </head> <body onload="onload_test()"> <h1>Description</h1> - <p>This test validates that, within child documents, all of the Page Visibility API attributes exist, + <p>This test validates that, within child documents, all of the Page Visibility API attributes exist, are read-only, and match the value of the attributes within the parent document.</p> <div id="log"></div> - + <br/> - + <div class="docs"> IFrame with no style attribute <br/> @@ -72,7 +73,7 @@ iframes unsupported </iframe> </div> - + <div class="docs"> IFrame with "display:none" style<br/> <iframe id="'display:none' style" style="display:none" @@ -80,7 +81,7 @@ iframes unsupported </iframe> </div> - + <div class="docs"> IFrame with "visibility:hidden" style <br/> diff --git a/page-visibility/test_default_view.html b/page-visibility/test_default_view.html index baa82f1..6e2f970 100644 --- a/page-visibility/test_default_view.html +++ b/page-visibility/test_default_view.html
@@ -4,10 +4,11 @@ <meta charset="utf-8" /> <title>Page Visibility Null Default View Test</title> <link rel="author" title="Microsoft" href="http://www.microsoft.com/" /> - - <script type="text/javascript" src="/resources/testharness.js"></script> + + <script src="/resources/testharness.js"></script> + <script src="/resources/testharnessreport.js"></script> <script type="text/javascript" src="resources/pagevistestharness.js"></script> - + <script type="text/javascript" > setup({explicit_done: true}); @@ -18,15 +19,15 @@ // Test precondition: ensure subdocument has a null default view test_true(subDoc.defaultView == null, "windowless subdocument generated for test has a null default view"); - + // check that feature exists within subdocument test_feature_exists(subDoc, 'windowless subdocument'); - + // check that the subdocument has a hidden visibility state test_true(subDoc.hidden, "hidden == true for windowless subdocuments with a null default view"); test_equals(subDoc.visibilityState, VISIBILITY_STATES.HIDDEN, - "visibilityState == " + VISIBILITY_STATES.HIDDEN + + "visibilityState == " + VISIBILITY_STATES.HIDDEN + " for windowless subdocuments with a null default view"); done(); @@ -35,7 +36,7 @@ </head> <body onload="onload_test()"> <h1>Description</h1> - <p>This test validates that document.hidden == false and + <p>This test validates that document.hidden == false and document.visibilityState == "visible" for windowless subdocuments.</p> <div id="log"></div> </body> diff --git a/page-visibility/test_read_only.html b/page-visibility/test_read_only.html index cc0085c..6d37022 100644 --- a/page-visibility/test_read_only.html +++ b/page-visibility/test_read_only.html
@@ -3,19 +3,20 @@ <head> <meta charset="utf-8" /> <title>Page Visibility API is Read Only</title> - - <script type="text/javascript" src="/resources/testharness.js"></script> + + <script src="/resources/testharness.js"></script> + <script src="/resources/testharnessreport.js"></script> <script type="text/javascript" src="resources/pagevistestharness.js"></script> - + <script type="text/javascript"> setup({ explicit_done: true }); function onload_test() { //check for feature definition first before attempting to overwrite pv_test(); - + //Check document.hidden - document.hidden = "new value"; + document.hidden = "new value"; test_true(document.hidden !== "new value", 'document.hidden is read only.'); //Check document.visibilityState diff --git a/proximity/ProximityEvent_tests.html b/proximity/ProximityEvent_tests.html index b723ba0..d89ec67 100644 --- a/proximity/ProximityEvent_tests.html +++ b/proximity/ProximityEvent_tests.html
@@ -5,5 +5,6 @@ <h1>Test Suite for Proximity Events</h1> <div id="log"></div> <script src="/resources/testharness.js"></script> +<script src="/resources/testharnessreport.js"></script> <script src="DeviceProximityEvent_tests.js"></script> <script src="UserProximityEvent_tests.js"></script>
diff --git a/resource-timing/resources/resource_timing_test0.css b/resource-timing/resources/resource_timing_test0.css index 9ee97b2..8bc8326 100644 --- a/resource-timing/resources/resource_timing_test0.css +++ b/resource-timing/resources/resource_timing_test0.css
@@ -1,4 +1,4 @@ -div#resource_link_css -{ - color:hotpink; +div#resource_link_css +{ + color:hotpink; } \ No newline at end of file diff --git a/resource-timing/resources/resource_timing_test0.html b/resource-timing/resources/resource_timing_test0.html index 4b4ab51..167c65c 100644 --- a/resource-timing/resources/resource_timing_test0.html +++ b/resource-timing/resources/resource_timing_test0.html
@@ -1,15 +1,15 @@ -<!DOCTYPE html> -<html> - <head> - <title> - Child Frame - </title> - </head> - <body style="background-color: #C0C0C0"> - - <h1> - Child Document - </h1> - - </body> +<!DOCTYPE html> +<html> + <head> + <title> + Child Frame + </title> + </head> + <body style="background-color: #C0C0C0"> + + <h1> + Child Document + </h1> + + </body> </html> \ No newline at end of file
diff --git a/resource-timing/resources/resource_timing_test0.js b/resource-timing/resources/resource_timing_test0.js index 84dc7cd..cf1c1df 100644 --- a/resource-timing/resources/resource_timing_test0.js +++ b/resource-timing/resources/resource_timing_test0.js
@@ -1,3 +1,3 @@ -// This is a test script for purposes of testing the -// script initiator type in the Resource Timing feature -var testDummyValue = 0; \ No newline at end of file +// This is a test script for purposes of testing the +// script initiator type in the Resource Timing feature +var testDummyValue = 0;
diff --git a/resource-timing/resources/resource_timing_test0.xml b/resource-timing/resources/resource_timing_test0.xml index 83599bf..91cd676 100644 --- a/resource-timing/resources/resource_timing_test0.xml +++ b/resource-timing/resources/resource_timing_test0.xml
@@ -1,6 +1,6 @@ -<?xml version="1.0" encoding="ISO-8859-1"?> -<TESTDATA> - <ITEM> - <DATA>Test XML Data</DATA> - </ITEM> -</TESTDATA> +<?xml version="1.0" encoding="ISO-8859-1"?> +<TESTDATA> + <ITEM> + <DATA>Test XML Data</DATA> + </ITEM> +</TESTDATA>
diff --git a/resource-timing/resources/webperftestharness.js b/resource-timing/resources/webperftestharness.js index 88418d9..98b2954 100644 --- a/resource-timing/resources/webperftestharness.js +++ b/resource-timing/resources/webperftestharness.js
@@ -1,145 +1,145 @@ -// -// Helper Functions for NavigationTiming W3C tests -// - -var performanceNamespace = window.performance; -var timingAttributes = [ - 'connectEnd', - 'connectStart', - 'domComplete', - 'domContentLoadedEventEnd', - 'domContentLoadedEventStart', - 'domInteractive', - 'domLoading', - 'domainLookupEnd', - 'domainLookupStart', - 'fetchStart', - 'loadEventEnd', - 'loadEventStart', - 'navigationStart', - 'redirectEnd', - 'redirectStart', - 'requestStart', - 'responseEnd', - 'responseStart', - 'unloadEventEnd', - 'unloadEventStart' -]; - -var namespace_check = false; - -// -// All test() functions in the WebPerf test suite should use wp_test() instead. -// -// wp_test() validates the window.performance namespace exists prior to running tests and -// immediately shows a single failure if it does not. -// - -function wp_test(func, msg, properties) -{ - // only run the namespace check once - if (!namespace_check) - { - namespace_check = true; - - if (performanceNamespace === undefined || performanceNamespace == null) - { - // show a single error that window.performance is undefined - test(function() { assert_true(performanceNamespace !== undefined && performanceNamespace != null, "window.performance is defined and not null"); }, "window.performance is defined and not null.", {author:"W3C http://www.w3.org/",help:"http://www.w3.org/TR/navigation-timing/#sec-window.performance-attribute",assert:"The window.performance attribute provides a hosting area for performance related attributes. "}); - } - } - - test(func, msg, properties); -} - -function test_namespace(child_name, skip_root) -{ - if (skip_root === undefined) { - var msg = 'window.performance is defined'; - wp_test(function () { assert_true(performanceNamespace !== undefined, msg); }, msg,{author:"W3C http://www.w3.org/",help:"http://www.w3.org/TR/navigation-timing/#sec-window.performance-attribute",assert:"The window.performance attribute provides a hosting area for performance related attributes. "}); - } - - if (child_name !== undefined) { - var msg2 = 'window.performance.' + child_name + ' is defined'; - wp_test(function() { assert_true(performanceNamespace[child_name] !== undefined, msg2); }, msg2,{author:"W3C http://www.w3.org/",help:"http://www.w3.org/TR/navigation-timing/#sec-window.performance-attribute",assert:"The window.performance attribute provides a hosting area for performance related attributes. "}); - } -} - -function test_attribute_exists(parent_name, attribute_name, properties) -{ - var msg = 'window.performance.' + parent_name + '.' + attribute_name + ' is defined.'; - wp_test(function() { assert_true(performanceNamespace[parent_name][attribute_name] !== undefined, msg); }, msg, properties); -} - -function test_enum(parent_name, enum_name, value, properties) -{ - var msg = 'window.performance.' + parent_name + '.' + enum_name + ' is defined.'; - wp_test(function() { assert_true(performanceNamespace[parent_name][enum_name] !== undefined, msg); }, msg, properties); - - msg = 'window.performance.' + parent_name + '.' + enum_name + ' = ' + value; - wp_test(function() { assert_equals(performanceNamespace[parent_name][enum_name], value, msg); }, msg, properties); -} - -function test_timing_order(attribute_name, greater_than_attribute, properties) -{ - // ensure it's not 0 first - var msg = "window.performance.timing." + attribute_name + " > 0"; - wp_test(function() { assert_true(performanceNamespace.timing[attribute_name] > 0, msg); }, msg, properties); - - // ensure it's in the right order - msg = "window.performance.timing." + attribute_name + " >= window.performance.timing." + greater_than_attribute; - wp_test(function() { assert_true(performanceNamespace.timing[attribute_name] >= performanceNamespace.timing[greater_than_attribute], msg); }, msg, properties); -} - -function test_timing_greater_than(attribute_name, greater_than, properties) -{ - var msg = "window.performance.timing." + attribute_name + " > " + greater_than; - test_greater_than(performanceNamespace.timing[attribute_name], greater_than, msg, properties); -} - -function test_timing_equals(attribute_name, equals, msg, properties) -{ - var test_msg = msg || "window.performance.timing." + attribute_name + " == " + equals; - test_equals(performanceNamespace.timing[attribute_name], equals, test_msg, properties); -} - -// -// Non-test related helper functions -// - -function sleep_milliseconds(n) -{ - var start = new Date().getTime(); - while (true) { - if ((new Date().getTime() - start) >= n) break; - } -} - -// -// Common helper functions -// - -function test_true(value, msg, properties) -{ - wp_test(function () { assert_true(value, msg); }, msg, properties); -} - -function test_equals(value, equals, msg, properties) -{ - wp_test(function () { assert_equals(value, equals, msg); }, msg, properties); -} - -function test_greater_than(value, greater_than, msg, properties) -{ - wp_test(function () { assert_true(value > greater_than, msg); }, msg, properties); -} - -function test_greater_or_equals(value, greater_than, msg, properties) -{ - wp_test(function () { assert_true(value >= greater_than, msg); }, msg, properties); -} - -function test_not_equals(value, notequals, msg, properties) -{ - wp_test(function() { assert_true(value !== notequals, msg); }, msg, properties); -} +// +// Helper Functions for NavigationTiming W3C tests +// + +var performanceNamespace = window.performance; +var timingAttributes = [ + 'connectEnd', + 'connectStart', + 'domComplete', + 'domContentLoadedEventEnd', + 'domContentLoadedEventStart', + 'domInteractive', + 'domLoading', + 'domainLookupEnd', + 'domainLookupStart', + 'fetchStart', + 'loadEventEnd', + 'loadEventStart', + 'navigationStart', + 'redirectEnd', + 'redirectStart', + 'requestStart', + 'responseEnd', + 'responseStart', + 'unloadEventEnd', + 'unloadEventStart' +]; + +var namespace_check = false; + +// +// All test() functions in the WebPerf test suite should use wp_test() instead. +// +// wp_test() validates the window.performance namespace exists prior to running tests and +// immediately shows a single failure if it does not. +// + +function wp_test(func, msg, properties) +{ + // only run the namespace check once + if (!namespace_check) + { + namespace_check = true; + + if (performanceNamespace === undefined || performanceNamespace == null) + { + // show a single error that window.performance is undefined + test(function() { assert_true(performanceNamespace !== undefined && performanceNamespace != null, "window.performance is defined and not null"); }, "window.performance is defined and not null.", {author:"W3C http://www.w3.org/",help:"http://www.w3.org/TR/navigation-timing/#sec-window.performance-attribute",assert:"The window.performance attribute provides a hosting area for performance related attributes. "}); + } + } + + test(func, msg, properties); +} + +function test_namespace(child_name, skip_root) +{ + if (skip_root === undefined) { + var msg = 'window.performance is defined'; + wp_test(function () { assert_true(performanceNamespace !== undefined, msg); }, msg,{author:"W3C http://www.w3.org/",help:"http://www.w3.org/TR/navigation-timing/#sec-window.performance-attribute",assert:"The window.performance attribute provides a hosting area for performance related attributes. "}); + } + + if (child_name !== undefined) { + var msg2 = 'window.performance.' + child_name + ' is defined'; + wp_test(function() { assert_true(performanceNamespace[child_name] !== undefined, msg2); }, msg2,{author:"W3C http://www.w3.org/",help:"http://www.w3.org/TR/navigation-timing/#sec-window.performance-attribute",assert:"The window.performance attribute provides a hosting area for performance related attributes. "}); + } +} + +function test_attribute_exists(parent_name, attribute_name, properties) +{ + var msg = 'window.performance.' + parent_name + '.' + attribute_name + ' is defined.'; + wp_test(function() { assert_true(performanceNamespace[parent_name][attribute_name] !== undefined, msg); }, msg, properties); +} + +function test_enum(parent_name, enum_name, value, properties) +{ + var msg = 'window.performance.' + parent_name + '.' + enum_name + ' is defined.'; + wp_test(function() { assert_true(performanceNamespace[parent_name][enum_name] !== undefined, msg); }, msg, properties); + + msg = 'window.performance.' + parent_name + '.' + enum_name + ' = ' + value; + wp_test(function() { assert_equals(performanceNamespace[parent_name][enum_name], value, msg); }, msg, properties); +} + +function test_timing_order(attribute_name, greater_than_attribute, properties) +{ + // ensure it's not 0 first + var msg = "window.performance.timing." + attribute_name + " > 0"; + wp_test(function() { assert_true(performanceNamespace.timing[attribute_name] > 0, msg); }, msg, properties); + + // ensure it's in the right order + msg = "window.performance.timing." + attribute_name + " >= window.performance.timing." + greater_than_attribute; + wp_test(function() { assert_true(performanceNamespace.timing[attribute_name] >= performanceNamespace.timing[greater_than_attribute], msg); }, msg, properties); +} + +function test_timing_greater_than(attribute_name, greater_than, properties) +{ + var msg = "window.performance.timing." + attribute_name + " > " + greater_than; + test_greater_than(performanceNamespace.timing[attribute_name], greater_than, msg, properties); +} + +function test_timing_equals(attribute_name, equals, msg, properties) +{ + var test_msg = msg || "window.performance.timing." + attribute_name + " == " + equals; + test_equals(performanceNamespace.timing[attribute_name], equals, test_msg, properties); +} + +// +// Non-test related helper functions +// + +function sleep_milliseconds(n) +{ + var start = new Date().getTime(); + while (true) { + if ((new Date().getTime() - start) >= n) break; + } +} + +// +// Common helper functions +// + +function test_true(value, msg, properties) +{ + wp_test(function () { assert_true(value, msg); }, msg, properties); +} + +function test_equals(value, equals, msg, properties) +{ + wp_test(function () { assert_equals(value, equals, msg); }, msg, properties); +} + +function test_greater_than(value, greater_than, msg, properties) +{ + wp_test(function () { assert_true(value > greater_than, msg); }, msg, properties); +} + +function test_greater_or_equals(value, greater_than, msg, properties) +{ + wp_test(function () { assert_true(value >= greater_than, msg); }, msg, properties); +} + +function test_not_equals(value, notequals, msg, properties) +{ + wp_test(function() { assert_true(value !== notequals, msg); }, msg, properties); +} diff --git a/resource-timing/test_resource_timing.html b/resource-timing/test_resource_timing.html index c8a56e5..e1e068c 100644 --- a/resource-timing/test_resource_timing.html +++ b/resource-timing/test_resource_timing.html
@@ -1,360 +1,360 @@ -<!DOCTYPE html> -<html> - <head> - <meta charset="UTF-8" /> - <title>window.performance Resource Timing Entries exist</title> - <link rel="author" title="Microsoft" href="http://www.microsoft.com/" /> - <link rel="help" href="http://w3c-test.org/webperf/specs/ResourceTiming/"/> - - <script src="/resources/testharness.js"></script> - <script src="/resources/testharnessreport.js"></script> - <script src="resources/webperftestharness.js"></script> - - <script> - var index = window.location.pathname.lastIndexOf('/'); - var pathname = window.location.pathname.substring(0, index) + '/'; - - var URL_PREFIX = pathname + "resources/"; - var TEST_TIMEOUT = 30 * 1000; //Test will timeout in 30 seconds - var TEST_ALLOWED_TIMING_DELTA = 20; - - var waitTimer; - var expectedEntries = new Array(); - - var initiatorTypes = ["iframe", "img", "link", "script", "xmlhttprequest"]; - - setup({timeout:TEST_TIMEOUT + 1000, explicit_done: true}); - - test_namespace(); - - /*===================================================================== - // Object entry - // Object representing an expected entry on the page. - =====================================================================*/ - function entry(name, startTime, initiatorType) - { - this.name = name; - this.startTime = startTime; - this.initiatorType = initiatorType; - }; - - /*===================================================================== - // function get_now() - // Returns a (high-res if possible) timestamp as a delta from - // navigationStart - =====================================================================*/ - function get_now() - { - if (window.performance.now !== undefined) - { - return window.performance.now(); - } - else - { - return (new Date() - window.performance.timing.navigationStart); - } - } - - /*===================================================================== - // function onload_test - // Main entry point to test. This will add all of the test resources - // to the page. For resources which will not fire an onload event, - // an entry object is created here. - =====================================================================*/ - function onload_test() - { - // check that the Performance Timeline API exists - test_true(window.performance.getEntriesByName !== undefined, - "window.performance.getEntriesByName() is defined"); - test_true(window.performance.getEntriesByType !== undefined, - "window.performance.getEntriesByType() is defined"); - test_true(window.performance.getEntries !== undefined, - "window.performance.getEntries() is defined"); - - //Early bail out if Performance Timeline APIs do not exist - if (window.performance.getEntriesByName == undefined || - window.performance.getEntriesByType == undefined || - window.performance.getEntries == undefined) - { - done(); - return; - } - else - { - // initialize expected entries array - expectedEntries = new Array(); - - // add elements to the page. We do this here so that we can - // control the start time for validation later - for (var type in initiatorTypes) - { - var startTime = get_now(); - var element = document.createElement(initiatorTypes[type]); - - switch (initiatorTypes[type]) - { - case "iframe": - element.src = URL_PREFIX + "resource_timing_test0.html"; - break; - case "img": - element.src = URL_PREFIX + "resource_timing_test0.png"; - break; - case "link": - element.rel = "Stylesheet"; - element.type = "text/css"; - element.href = URL_PREFIX + "resource_timing_test0.css"; - break; - case "script": - element.type = "text/javascript"; - element.src = URL_PREFIX + "resource_timing_test0.js"; - break; - case "xmlhttprequest": - element = document.createElement("div"); - element.innerHTML = ""; - var xmlhttp = new XMLHttpRequest(); - xmlhttp.open('GET', URL_PREFIX + "resource_timing_test0.xml", false); - xmlhttp.send(); - element.innerText = xmlhttp.responseText; - expectedEntries.push(new entry(URL_PREFIX + "resource_timing_test0.xml", - startTime, - "xmlhttprequest")); - document.getElementById("xmlhttprequest").appendChild(element); - break; - } - - element.setAttribute("onload", "resource_load(event, " + startTime + ")"); - document.getElementById(initiatorTypes[type]).appendChild(element); - } - } - } - - /*===================================================================== - // function resource_load() - // Onload event handler for added test resources. - // This will create a new entry object for validation. - =====================================================================*/ - function resource_load(event, startTime) - { - var x = event.target || event.srcElement; - var type; - switch (x.localName) - { - case "css": - type = "link"; - break; - case "iframe": - type = "subdocument"; - break; - default: - type = x.localName - } - expectedEntries.push(new entry((x.href || x.src), - (startTime == undefined ? 0 : startTime), //use earliest possible time if not defined - type)); - - //Check if we have loaded all of our defined initiators. - //Validate the test if they are all present, otherwise set the - //test timeout timer. - if (expectedEntries.length == initiatorTypes.length) - { - clearTimeout(waitTimer); - validate(); - done(); - } - else - { - clearTimeout(waitTimer); - waitTimer = setTimeout(timeout_test, TEST_TIMEOUT); - } - } - - /*===================================================================== - // function timeout_test() - // If TEST_TIMEOUT time has elapsed since the last onload event handler - // has fired, then we will fail the rest of the test to avoid appearing - // hung. - =====================================================================*/ - function timeout_test() - { - test_true(false, "All expected resources did not load within a " + - "test timeout of " + TEST_TIMEOUT + "ms" + - "Only a subset of the tests will execute."); - done(); - } - - /*===================================================================== - // function validate() - // Verifies that each of the expected entry objects are discoverable - // in the Performance Timeline via getEntriesByName('name') and - // getEntriesByName('name', 'resource') and that their data is correct. - =====================================================================*/ - function validate() - { - for (var i in expectedEntries) - { - var name = expectedEntries[i].name; - var entriesByName = window.performance.getEntriesByName(name); - test_equals(entriesByName.length, 1, - "window.performance.getEntriesByName(\"" + - name.replace(URL_PREFIX, "http://.../") + "\") " + - "returns a PerformanceEntry object"); - - if (entriesByName.length == 1) - { - test_entry(expectedEntries[i], entriesByName[0]); - - var entriesByNameWithType = window.performance.getEntriesByName(name, "resource"); - test_true(is_same_object(entriesByName[0], entriesByNameWithType[0]), - "PerformanceEntry object is the same when calling via getEntriesByName(\"" + - name.replace(URL_PREFIX, "http://.../") + "\") and getEntriesByName(\"" + - name.replace(URL_PREFIX, "http://.../") + "\", 'resource')"); - } - } - } - - /*===================================================================== - // function is_same_object() - // Validates whether obj1 has the same property values as obj2. - =====================================================================*/ - function is_same_object(obj1, obj2) - { - for (var prop in obj1) - { - if (obj1[prop] != obj2[prop]) - { - return false; - } - } - return true; - } - - /*===================================================================== - // function test_entry - // Validates an expected entry object against a recorded Performance - // Entry object; This checks that the name and initiatorType match, - // that the entryType is "resource", the startTime is within - // TEST_ALLOWED_TIMING_DELTA of the expected startTime, the duration - // is calculated from responseEnd to startTime, invalid timing - // properties are either 0 or undefined, and the timing attributes are - // in the correct order. - =====================================================================*/ - function test_entry(expectedEntry, actualEntry) - { - var entryDetails = "Name: Expected= '" + expectedEntry.name + - "' | Actual= '" + actualEntry.name + "'<br/>" + - "InitiatorType: Expected= '" + expectedEntry.initiatorType + - "' | Actual= '" + actualEntry.initiatorType + "'<br/>" + - "EntryType: Expected= 'resource'" + - "' | Actual= '" + actualEntry.entryType + "'<br/>" + - "StartTime: Expected= " + expectedEntry.startTime + - " | Actual= " + actualEntry.startTime + "<br/>" + - "Duration: Expected= " + (actualEntry.responseEnd - actualEntry.startTime) + - " | Actual= " + actualEntry.duration + "<br/>"; - - var pass = (expectedEntry.name == actualEntry.name) && - (expectedEntry.initiatorType == actualEntry.initiatorType) && - (actualEntry.entryType == "resource") && - (Math.abs(actualEntry.startTime - expectedEntry.startTime) < TEST_ALLOWED_TIMING_DELTA) && - (actualEntry.duration == (actualEntry.responseEnd - actualEntry.startTime)); - - (pass) ? test_true(true, - "PerformanceEntry returned by window.performance.getEntriesByName(\"" + - actualEntry.name.replace(URL_PREFIX, "http://.../") + "\") has correct name, " + - "initiatorType, startTime, and duration.") - : - test_true(false, - "PerformanceEntry returned by window.performance.getEntriesByName(\"" + - actualEntry.name.replace(URL_PREFIX, "http://.../") + "\") has correct name, " + - "initiatorType, startTime, and duration.<br/>" + - entryDetails); - - // validate timeline - var timelineDetails = "domainLookupStart >= fetchStart: " + - actualEntry.domainLookupStart + " >= " + actualEntry.fetchStart + "<br/>" + - "domainLookupEnd >= domainLookupStart: " + - actualEntry.domainLookupEnd + " >= " + actualEntry.domainLookupStart + "<br/>" + - "connectStart >= domainLookupEnd: " + - actualEntry.connectStart + " >= " + actualEntry.domainLookupEnd + "<br/>" + - "connectEnd >= connectStart: " + - actualEntry.connectEnd + " >= " + actualEntry.connectStart + "<br/>" + - "requestStart >= connectEnd: " + - actualEntry.requestStart + " >= " + actualEntry.connectEnd + "<br/>" + - "responseStart >= requestStart: " + - actualEntry.responseStart + " >= " + actualEntry.requestStart + "<br/>" + - "responseEnd >= responseStart: " + - actualEntry.responseEnd + " >= " + actualEntry.responseStart + "<br/>"; - - pass = (actualEntry.redirectStart == 0) && - (actualEntry.redirectEnd == 0) && - (actualEntry.secureConnectionStart == undefined) && - validate_timeline(actualEntry); - - (pass) ? test_true(true, - "PerformanceEntry returned by window.performance.getEntriesByName(\"" + - actualEntry.name.replace(URL_PREFIX, "http://.../") + "\") has correct order of " + - "timing attributes.") - : - test_true(false, - "PerformanceEntry has correct name, initiatorType, " + - actualEntry.name.replace(URL_PREFIX, "http://.../") + "\") has correct order of " + - "timing attributes.<br/>" + - timelineDetails); - } - - /*===================================================================== - // function validate_timeline - // Verifies that the timing attributes of the test entry are in the - // correct order. - =====================================================================*/ - function validate_timeline(entry) - { - return ((entry.domainLookupStart >= entry.fetchStart) && - (entry.domainLookupEnd >= entry.domainLookupStart) && - (entry.connectStart >= entry.domainLookupEnd) && - (entry.connectEnd >= entry.connectStart) && - (entry.requestStart >= entry.connectEnd) && - (entry.responseStart >= entry.requestStart) && - (entry.responseEnd >= entry.responseStart)); - } - </script> - - </head> - <body onload="onload_test();"> - <h1>Description</h1> - <p>This test validates that Resource Timing entries for resources - loaded on a page exist in the Performance Timeline. - <br /> - Resources for the following initiators are used: iframe, img, link, script, xml. - <br /> - NOTE: Due to caching behavior in the browser, it is possible that when revisiting this page, some resources - may not have to be fetched from the network. As a result, the performance timeline will not contain entries - for these resources. This test will fail if any entries are missing to ensure that all resources are fetched - from the network and entries for these resources exist in the Performance Timeline. If revisiting this page, - please either perform a full reload of the page or clear the cache between visits. In Internet Explorer 10, - a full reload is performed via the keyboard shortcut: ctrl + F5. - </p> - - <div id="log"></div> - - <div style="visibility:hidden"> - <table id="resources"> - <thead> - <tr> - <th>iframe</th> - <th>img</th> - <th>link</th> - <th>script</th> - <th>XMLHttpRequest</th> - </tr> - </thead> - <tr> - <td id="iframe"></td> - <td id="img"></td> - <td id="link"><div id="resource_link_css">div with test css</div></td> - <td id="script"></td> - <td id="xmlhttprequest"></td> - </tr> - </table> - </div> - </body> -</html> +<!DOCTYPE html> +<html> + <head> + <meta charset="UTF-8" /> + <title>window.performance Resource Timing Entries exist</title> + <link rel="author" title="Microsoft" href="http://www.microsoft.com/" /> + <link rel="help" href="http://w3c-test.org/webperf/specs/ResourceTiming/"/> + + <script src="/resources/testharness.js"></script> + <script src="/resources/testharnessreport.js"></script> + <script src="resources/webperftestharness.js"></script> + + <script> + var index = window.location.pathname.lastIndexOf('/'); + var pathname = window.location.pathname.substring(0, index) + '/'; + + var URL_PREFIX = pathname + "resources/"; + var TEST_TIMEOUT = 30 * 1000; //Test will timeout in 30 seconds + var TEST_ALLOWED_TIMING_DELTA = 20; + + var waitTimer; + var expectedEntries = new Array(); + + var initiatorTypes = ["iframe", "img", "link", "script", "xmlhttprequest"]; + + setup({timeout:TEST_TIMEOUT + 1000, explicit_done: true}); + + test_namespace(); + + /*===================================================================== + // Object entry + // Object representing an expected entry on the page. + =====================================================================*/ + function entry(name, startTime, initiatorType) + { + this.name = name; + this.startTime = startTime; + this.initiatorType = initiatorType; + }; + + /*===================================================================== + // function get_now() + // Returns a (high-res if possible) timestamp as a delta from + // navigationStart + =====================================================================*/ + function get_now() + { + if (window.performance.now !== undefined) + { + return window.performance.now(); + } + else + { + return (new Date() - window.performance.timing.navigationStart); + } + } + + /*===================================================================== + // function onload_test + // Main entry point to test. This will add all of the test resources + // to the page. For resources which will not fire an onload event, + // an entry object is created here. + =====================================================================*/ + function onload_test() + { + // check that the Performance Timeline API exists + test_true(window.performance.getEntriesByName !== undefined, + "window.performance.getEntriesByName() is defined"); + test_true(window.performance.getEntriesByType !== undefined, + "window.performance.getEntriesByType() is defined"); + test_true(window.performance.getEntries !== undefined, + "window.performance.getEntries() is defined"); + + //Early bail out if Performance Timeline APIs do not exist + if (window.performance.getEntriesByName == undefined || + window.performance.getEntriesByType == undefined || + window.performance.getEntries == undefined) + { + done(); + return; + } + else + { + // initialize expected entries array + expectedEntries = new Array(); + + // add elements to the page. We do this here so that we can + // control the start time for validation later + for (var type in initiatorTypes) + { + var startTime = get_now(); + var element = document.createElement(initiatorTypes[type]); + + switch (initiatorTypes[type]) + { + case "iframe": + element.src = URL_PREFIX + "resource_timing_test0.html"; + break; + case "img": + element.src = URL_PREFIX + "resource_timing_test0.png"; + break; + case "link": + element.rel = "Stylesheet"; + element.type = "text/css"; + element.href = URL_PREFIX + "resource_timing_test0.css"; + break; + case "script": + element.type = "text/javascript"; + element.src = URL_PREFIX + "resource_timing_test0.js"; + break; + case "xmlhttprequest": + element = document.createElement("div"); + element.innerHTML = ""; + var xmlhttp = new XMLHttpRequest(); + xmlhttp.open('GET', URL_PREFIX + "resource_timing_test0.xml", false); + xmlhttp.send(); + element.innerText = xmlhttp.responseText; + expectedEntries.push(new entry(URL_PREFIX + "resource_timing_test0.xml", + startTime, + "xmlhttprequest")); + document.getElementById("xmlhttprequest").appendChild(element); + break; + } + + element.setAttribute("onload", "resource_load(event, " + startTime + ")"); + document.getElementById(initiatorTypes[type]).appendChild(element); + } + } + } + + /*===================================================================== + // function resource_load() + // Onload event handler for added test resources. + // This will create a new entry object for validation. + =====================================================================*/ + function resource_load(event, startTime) + { + var x = event.target || event.srcElement; + var type; + switch (x.localName) + { + case "css": + type = "link"; + break; + case "iframe": + type = "subdocument"; + break; + default: + type = x.localName + } + expectedEntries.push(new entry((x.href || x.src), + (startTime == undefined ? 0 : startTime), //use earliest possible time if not defined + type)); + + //Check if we have loaded all of our defined initiators. + //Validate the test if they are all present, otherwise set the + //test timeout timer. + if (expectedEntries.length == initiatorTypes.length) + { + clearTimeout(waitTimer); + validate(); + done(); + } + else + { + clearTimeout(waitTimer); + waitTimer = setTimeout(timeout_test, TEST_TIMEOUT); + } + } + + /*===================================================================== + // function timeout_test() + // If TEST_TIMEOUT time has elapsed since the last onload event handler + // has fired, then we will fail the rest of the test to avoid appearing + // hung. + =====================================================================*/ + function timeout_test() + { + test_true(false, "All expected resources did not load within a " + + "test timeout of " + TEST_TIMEOUT + "ms" + + "Only a subset of the tests will execute."); + done(); + } + + /*===================================================================== + // function validate() + // Verifies that each of the expected entry objects are discoverable + // in the Performance Timeline via getEntriesByName('name') and + // getEntriesByName('name', 'resource') and that their data is correct. + =====================================================================*/ + function validate() + { + for (var i in expectedEntries) + { + var name = expectedEntries[i].name; + var entriesByName = window.performance.getEntriesByName(name); + test_equals(entriesByName.length, 1, + "window.performance.getEntriesByName(\"" + + name.replace(URL_PREFIX, "http://.../") + "\") " + + "returns a PerformanceEntry object"); + + if (entriesByName.length == 1) + { + test_entry(expectedEntries[i], entriesByName[0]); + + var entriesByNameWithType = window.performance.getEntriesByName(name, "resource"); + test_true(is_same_object(entriesByName[0], entriesByNameWithType[0]), + "PerformanceEntry object is the same when calling via getEntriesByName(\"" + + name.replace(URL_PREFIX, "http://.../") + "\") and getEntriesByName(\"" + + name.replace(URL_PREFIX, "http://.../") + "\", 'resource')"); + } + } + } + + /*===================================================================== + // function is_same_object() + // Validates whether obj1 has the same property values as obj2. + =====================================================================*/ + function is_same_object(obj1, obj2) + { + for (var prop in obj1) + { + if (obj1[prop] != obj2[prop]) + { + return false; + } + } + return true; + } + + /*===================================================================== + // function test_entry + // Validates an expected entry object against a recorded Performance + // Entry object; This checks that the name and initiatorType match, + // that the entryType is "resource", the startTime is within + // TEST_ALLOWED_TIMING_DELTA of the expected startTime, the duration + // is calculated from responseEnd to startTime, invalid timing + // properties are either 0 or undefined, and the timing attributes are + // in the correct order. + =====================================================================*/ + function test_entry(expectedEntry, actualEntry) + { + var entryDetails = "Name: Expected= '" + expectedEntry.name + + "' | Actual= '" + actualEntry.name + "'<br/>" + + "InitiatorType: Expected= '" + expectedEntry.initiatorType + + "' | Actual= '" + actualEntry.initiatorType + "'<br/>" + + "EntryType: Expected= 'resource'" + + "' | Actual= '" + actualEntry.entryType + "'<br/>" + + "StartTime: Expected= " + expectedEntry.startTime + + " | Actual= " + actualEntry.startTime + "<br/>" + + "Duration: Expected= " + (actualEntry.responseEnd - actualEntry.startTime) + + " | Actual= " + actualEntry.duration + "<br/>"; + + var pass = (expectedEntry.name == actualEntry.name) && + (expectedEntry.initiatorType == actualEntry.initiatorType) && + (actualEntry.entryType == "resource") && + (Math.abs(actualEntry.startTime - expectedEntry.startTime) < TEST_ALLOWED_TIMING_DELTA) && + (actualEntry.duration == (actualEntry.responseEnd - actualEntry.startTime)); + + (pass) ? test_true(true, + "PerformanceEntry returned by window.performance.getEntriesByName(\"" + + actualEntry.name.replace(URL_PREFIX, "http://.../") + "\") has correct name, " + + "initiatorType, startTime, and duration.") + : + test_true(false, + "PerformanceEntry returned by window.performance.getEntriesByName(\"" + + actualEntry.name.replace(URL_PREFIX, "http://.../") + "\") has correct name, " + + "initiatorType, startTime, and duration.<br/>" + + entryDetails); + + // validate timeline + var timelineDetails = "domainLookupStart >= fetchStart: " + + actualEntry.domainLookupStart + " >= " + actualEntry.fetchStart + "<br/>" + + "domainLookupEnd >= domainLookupStart: " + + actualEntry.domainLookupEnd + " >= " + actualEntry.domainLookupStart + "<br/>" + + "connectStart >= domainLookupEnd: " + + actualEntry.connectStart + " >= " + actualEntry.domainLookupEnd + "<br/>" + + "connectEnd >= connectStart: " + + actualEntry.connectEnd + " >= " + actualEntry.connectStart + "<br/>" + + "requestStart >= connectEnd: " + + actualEntry.requestStart + " >= " + actualEntry.connectEnd + "<br/>" + + "responseStart >= requestStart: " + + actualEntry.responseStart + " >= " + actualEntry.requestStart + "<br/>" + + "responseEnd >= responseStart: " + + actualEntry.responseEnd + " >= " + actualEntry.responseStart + "<br/>"; + + pass = (actualEntry.redirectStart == 0) && + (actualEntry.redirectEnd == 0) && + (actualEntry.secureConnectionStart == undefined) && + validate_timeline(actualEntry); + + (pass) ? test_true(true, + "PerformanceEntry returned by window.performance.getEntriesByName(\"" + + actualEntry.name.replace(URL_PREFIX, "http://.../") + "\") has correct order of " + + "timing attributes.") + : + test_true(false, + "PerformanceEntry has correct name, initiatorType, " + + actualEntry.name.replace(URL_PREFIX, "http://.../") + "\") has correct order of " + + "timing attributes.<br/>" + + timelineDetails); + } + + /*===================================================================== + // function validate_timeline + // Verifies that the timing attributes of the test entry are in the + // correct order. + =====================================================================*/ + function validate_timeline(entry) + { + return ((entry.domainLookupStart >= entry.fetchStart) && + (entry.domainLookupEnd >= entry.domainLookupStart) && + (entry.connectStart >= entry.domainLookupEnd) && + (entry.connectEnd >= entry.connectStart) && + (entry.requestStart >= entry.connectEnd) && + (entry.responseStart >= entry.requestStart) && + (entry.responseEnd >= entry.responseStart)); + } + </script> + + </head> + <body onload="onload_test();"> + <h1>Description</h1> + <p>This test validates that Resource Timing entries for resources + loaded on a page exist in the Performance Timeline. + <br /> + Resources for the following initiators are used: iframe, img, link, script, xml. + <br /> + NOTE: Due to caching behavior in the browser, it is possible that when revisiting this page, some resources + may not have to be fetched from the network. As a result, the performance timeline will not contain entries + for these resources. This test will fail if any entries are missing to ensure that all resources are fetched + from the network and entries for these resources exist in the Performance Timeline. If revisiting this page, + please either perform a full reload of the page or clear the cache between visits. In Internet Explorer 10, + a full reload is performed via the keyboard shortcut: ctrl + F5. + </p> + + <div id="log"></div> + + <div style="visibility:hidden"> + <table id="resources"> + <thead> + <tr> + <th>iframe</th> + <th>img</th> + <th>link</th> + <th>script</th> + <th>XMLHttpRequest</th> + </tr> + </thead> + <tr> + <td id="iframe"></td> + <td id="img"></td> + <td id="link"><div id="resource_link_css">div with test css</div></td> + <td id="script"></td> + <td id="xmlhttprequest"></td> + </tr> + </table> + </div> + </body> +</html> diff --git a/tools/scripts/lint.py b/tools/scripts/lint.py index 7717428..62dbf2a 100644 --- a/tools/scripts/lint.py +++ b/tools/scripts/lint.py
@@ -5,6 +5,14 @@ import fnmatch from collections import defaultdict +try: + from xml.etree import cElementTree as ElementTree +except ImportError: + from xml.etree import ElementTree + +import html5lib + +import manifest here = os.path.split(__file__)[0] @@ -89,6 +97,82 @@ return errors +def check_parsed(path, f): + ext = os.path.splitext(path)[1][1:] + + errors = [] + + if path.endswith("-manual.%s" % ext): + return [] + + parsers = {"html":lambda x:html5lib.parse(x, treebuilder="etree"), + "htm":lambda x:html5lib.parse(x, treebuilder="etree"), + "xhtml":ElementTree.parse, + "xhtm":ElementTree.parse, + "svg":ElementTree.parse} + + parser = parsers.get(ext) + + if parser is None: + return [] + + try: + tree = parser(f) + except: + return [("PARSE-FAILED", "Unable to parse file %s" % path, None)] + + if hasattr(tree, "getroot"): + root = tree.getroot() + else: + root = tree + + timeout_nodes = manifest.get_timeout_meta(root) + if len(timeout_nodes) > 1: + errors.append(("MULTIPLE-TIMEOUT", "%s more than one meta name='timeout'" % path, None)) + + for timeout_node in timeout_nodes: + timeout_value = timeout_node.attrib.get("content", "").lower() + if timeout_value != "long": + errors.append(("INVALID-TIMEOUT", "%s invalid timeout value %s" % (path, timeout_value), None)) + + testharness_nodes = manifest.get_testharness_scripts(root) + if testharness_nodes: + if len(testharness_nodes) > 1: + errors.append(("MULTIPLE-TESTHARNESS", "%s more than one <script src='/resources/testharness.js>'" % path, None)) + + testharnessreport_nodes = root.findall(".//{http://www.w3.org/1999/xhtml}script[@src='/resources/testharnessreport.js']") + if not testharnessreport_nodes: + errors.append(("MISSING-TESTHARNESSREPORT", "%s missing <script src='/resources/testharnessreport.js>'" % path, None)) + else: + if len(testharnessreport_nodes) > 1: + errors.append(("MULTIPLE-TESTHARNESSREPORT", "%s more than one <script src='/resources/testharnessreport.js>'" % path, None)) + + seen_elements = {"timeout": False, + "testharness": False, + "testharnessreport": False} + required_elements = [key for key, value in {"testharness": True, + "testharnessreport": len(testharnessreport_nodes) > 0, + "timeout": len(timeout_nodes) > 0}.iteritems() if value] + + for elem in root.iter(): + if timeout_nodes and elem == timeout_nodes[0]: + seen_elements["timeout"] = True + if seen_elements["testharness"]: + errors.append(("LATE-TIMEOUT", "%s <meta name=timeout> seen after testharness.js script" % path, None)) + + elif elem == testharness_nodes[0]: + seen_elements["testharness"] = True + + elif testharnessreport_nodes and elem == testharnessreport_nodes[0]: + seen_elements["testharnessreport"] = True + if not seen_elements["testharness"]: + errors.append(("EARLY-TESTHARNESSREPORT", "%s testharnessreport.js script seen before testharness.js script" % path, None)) + + if all(seen_elements[name] for name in required_elements): + break + + return errors + def output_errors(errors): for error_type, error, line_number in errors: print "%s: %s" % (error_type, error) @@ -115,6 +199,8 @@ for path in iter_files(): abs_path = os.path.join(repo_root, path) + if not os.path.exists(path): + continue for path_fn in path_lints: run_lint(path, path_fn) @@ -122,12 +208,13 @@ with open(abs_path) as f: for file_fn in file_lints: run_lint(path, file_fn, f) + f.seek(0) output_error_count(error_count) return sum(error_count.itervalues()) path_lints = [check_path_length] -file_lints = [check_whitespace] +file_lints = [check_whitespace, check_parsed] if __name__ == "__main__": error_count = main() diff --git a/tools/scripts/lint.whitelist b/tools/scripts/lint.whitelist index 801a557..fef3ef3 100644 --- a/tools/scripts/lint.whitelist +++ b/tools/scripts/lint.whitelist
@@ -21,3 +21,11 @@ CR AT EOL:*.webm CR AT EOL:*.mp4 CR AT EOL:*.m4v +PARSE-FAILED:dom/nodes/Document-createElement-namespace-tests/empty.svg +PARSE-FAILED:dom/nodes/Document-createElement-namespace-tests/empty.xhtml +PARSE-FAILED:dom/nodes/Document-createElement-namespace-tests/minimal_html.svg +PARSE-FAILED:dom/nodes/Document-createElement-namespace-tests/minimal_html.xhtml +#These have undefined entities; should probably find a way to define them +PARSE-FAILED:ext-xhtml-pubid/the-xhtml-syntax/parsing-xhtml-documents/xhtml-pubid-1.xhtml +PARSE-FAILED:ext-xhtml-pubid/the-xhtml-syntax/parsing-xhtml-documents/xhtml-pubid-2.xhtml +PARSE-FAILED:ext-xhtml-pubid/the-xhtml-syntax/parsing-xhtml-documents/xhtml-pubid-3.xhtml
diff --git a/tools/scripts/manifest.py b/tools/scripts/manifest.py index c15ab09..0f74f5b 100644 --- a/tools/scripts/manifest.py +++ b/tools/scripts/manifest.py
@@ -231,6 +231,20 @@ return None +def get_timeout_meta(root): + return root.findall(".//{http://www.w3.org/1999/xhtml}meta[@name='timeout']") + + +def get_testharness_scripts(root): + return root.findall(".//{http://www.w3.org/1999/xhtml}script[@src='/resources/testharness.js']") + + +def get_reference_links(root): + match_links = root.findall(".//{http://www.w3.org/1999/xhtml}link[@rel='match']") + mismatch_links = root.findall(".//{http://www.w3.org/1999/xhtml}link[@rel='mismatch']") + return match_links, mismatch_links + + def get_manifest_items(rel_path): if rel_path.endswith(os.path.sep): return [] @@ -294,7 +308,7 @@ else: root = tree - timeout_nodes = root.findall(".//{http://www.w3.org/1999/xhtml}meta[@name='timeout']") + timeout_nodes = get_timeout_meta(root) if timeout_nodes: timeout_str = timeout_nodes[0].attrib.get("content", None) if timeout_str and timeout_str.lower() == "long": @@ -303,11 +317,10 @@ except: pass - if root.findall(".//{http://www.w3.org/1999/xhtml}script[@src='/resources/testharness.js']"): + if get_testharness_scripts(root): return [TestharnessTest(rel_path, url, timeout=timeout)] else: - match_links = root.findall(".//{http://www.w3.org/1999/xhtml}link[@rel='match']") - mismatch_links = root.findall(".//{http://www.w3.org/1999/xhtml}link[@rel='mismatch']") + match_links, mismatch_links = get_reference_links(root) for item in match_links + mismatch_links: ref_url = urlparse.urljoin(url, item.attrib["href"]) ref_type = "==" if item.attrib["rel"] == "match" else "!=" diff --git a/touch-events/create-touch-touchlist.html b/touch-events/create-touch-touchlist.html index ee343f5..502090c 100644 --- a/touch-events/create-touch-touchlist.html +++ b/touch-events/create-touch-touchlist.html
@@ -18,167 +18,168 @@ <title>Touch Events createTouch and createTouchList Interface Tests</title> <meta name="viewport" content="width=device-width"> <script src="/resources/testharness.js"></script> +<script src="/resources/testharnessreport.js"></script> <script> - setup({explicit_done: true}); + setup({explicit_done: true}); - // Check a Touch object's atttributes for existence and correct type - // TA: 1.1.2, 1.1.3 - function check_Touch_object (t) { - test(function() { - assert_equals(Object.prototype.toString.call(t), "[object Touch]", "touch is of type Touch"); - }, "touch point is a Touch object"); - [ - ["long", "identifier"], - ["EventTarget", "target"], - ["long", "screenX"], - ["long", "screenY"], - ["long", "clientX"], - ["long", "clientY"], - ["long", "pageX"], - ["long", "pageY"], - ].forEach(function(attr) { - var type = attr[0]; - var name = attr[1]; + // Check a Touch object's atttributes for existence and correct type + // TA: 1.1.2, 1.1.3 + function check_Touch_object (t) { + test(function() { + assert_equals(Object.prototype.toString.call(t), "[object Touch]", "touch is of type Touch"); + }, "touch point is a Touch object"); + [ + ["long", "identifier"], + ["EventTarget", "target"], + ["long", "screenX"], + ["long", "screenY"], + ["long", "clientX"], + ["long", "clientY"], + ["long", "pageX"], + ["long", "pageY"], + ].forEach(function(attr) { + var type = attr[0]; + var name = attr[1]; - // existence check - test(function() { - assert_true(name in t, name + " attribute in Touch object"); - }, "Touch." + name + " attribute exists"); + // existence check + test(function() { + assert_true(name in t, name + " attribute in Touch object"); + }, "Touch." + name + " attribute exists"); - // type check - switch(type) { - case "long": - test(function() { - assert_equals(typeof t[name], "number", name + " attribute of type long"); - }, "Touch." + name + " attribute is of type number (long)"); - break; - case "EventTarget": - // An event target is some type of Element - test(function() { - assert_true(t[name] instanceof Element, "EventTarget must be an Element."); - }, "Touch." + name + " attribute is of type Element"); - break; - default: - break; - } - }); - } + // type check + switch(type) { + case "long": + test(function() { + assert_equals(typeof t[name], "number", name + " attribute of type long"); + }, "Touch." + name + " attribute is of type number (long)"); + break; + case "EventTarget": + // An event target is some type of Element + test(function() { + assert_true(t[name] instanceof Element, "EventTarget must be an Element."); + }, "Touch." + name + " attribute is of type Element"); + break; + default: + break; + } + }); + } - // Check a TouchList object's attributes and methods for existence and proper type - // Also make sure all of the members of the list are Touch objects - // TA: 1.2.1, 1.2.2, 1.2.5, 1.2.6 - function check_TouchList_object (tl) { - test(function() { - assert_equals(Object.prototype.toString.call(tl), "[object TouchList]", "touch list is of type TouchList"); - }, "touch list is a TouchList object"); - [ - ["unsigned long", "length"], - ["function", "item"], - ].forEach(function(attr) { - var type = attr[0]; - var name = attr[1]; + // Check a TouchList object's attributes and methods for existence and proper type + // Also make sure all of the members of the list are Touch objects + // TA: 1.2.1, 1.2.2, 1.2.5, 1.2.6 + function check_TouchList_object (tl) { + test(function() { + assert_equals(Object.prototype.toString.call(tl), "[object TouchList]", "touch list is of type TouchList"); + }, "touch list is a TouchList object"); + [ + ["unsigned long", "length"], + ["function", "item"], + ].forEach(function(attr) { + var type = attr[0]; + var name = attr[1]; - // existence check - test(function() { - assert_true(name in tl, name + " attribute in TouchList"); - }, "TouchList." + name + " attribute exists"); + // existence check + test(function() { + assert_true(name in tl, name + " attribute in TouchList"); + }, "TouchList." + name + " attribute exists"); - // type check - switch(type) { - case "unsigned long": - test(function() { - assert_equals(typeof tl[name], "number", name + " attribute of type long"); - }, "TouchList." + name + " attribute is of type number (unsigned long)"); - break; - case "function": - test(function() { - assert_equals(typeof tl[name], "function", name + " attribute of type function"); - }, "TouchList." + name + " attribute is of type function"); - break; - default: - break; - } - }); - // Each member of tl should be a proper Touch object - for (var i=0; i < tl.length; i++) { - check_Touch_object(tl.item(i)); - } - // TouchList.item(x) should return null if x is >= TouchList.length - test(function() { - var t = tl.item(tl.length); - assert_equals(t, null, "TouchList.item(TouchList.length) must return null"); - }, "TouchList.item returns null if the index is >= the length of the list"); - } + // type check + switch(type) { + case "unsigned long": + test(function() { + assert_equals(typeof tl[name], "number", name + " attribute of type long"); + }, "TouchList." + name + " attribute is of type number (unsigned long)"); + break; + case "function": + test(function() { + assert_equals(typeof tl[name], "function", name + " attribute of type function"); + }, "TouchList." + name + " attribute is of type function"); + break; + default: + break; + } + }); + // Each member of tl should be a proper Touch object + for (var i=0; i < tl.length; i++) { + check_Touch_object(tl.item(i)); + } + // TouchList.item(x) should return null if x is >= TouchList.length + test(function() { + var t = tl.item(tl.length); + assert_equals(t, null, "TouchList.item(TouchList.length) must return null"); + }, "TouchList.item returns null if the index is >= the length of the list"); + } function check_touch_clientXY(touch) { - assert_equals(touch.clientX, touch.pageX - window.pageXOffset, "touch.clientX is touch.pageX - window.pageXOffset."); - assert_equals(touch.clientY, touch.pageY - window.pageYOffset, "touch.clientY is touch.pageY - window.pageYOffset."); + assert_equals(touch.clientX, touch.pageX - window.pageXOffset, "touch.clientX is touch.pageX - window.pageXOffset."); + assert_equals(touch.clientY, touch.pageY - window.pageYOffset, "touch.clientY is touch.pageY - window.pageYOffset."); } - function run() { - var target0 = document.getElementById("target0"); - var touch1, touch2; + function run() { + var target0 = document.getElementById("target0"); + var touch1, touch2; - test(function() { - touch1 = document.createTouch(window, target0, 42, 15, 20, 35, 40); - assert_equals(touch1.target, target0, "touch.target is target0"); - assert_equals(touch1.identifier, 42, "touch.identifier is requested value"); - assert_equals(touch1.pageX, 15, "touch.pageX is requested value"); - assert_equals(touch1.pageY, 20, "touch.pageY is requested value"); - check_touch_clientXY(touch1); - assert_equals(touch1.screenX, 35, "touch.screenX is requested value"); - assert_equals(touch1.screenY, 40, "touch.screenY is requested value"); - }, "document.createTouch exists and creates a Touch object with requested properties"); + test(function() { + touch1 = document.createTouch(window, target0, 42, 15, 20, 35, 40); + assert_equals(touch1.target, target0, "touch.target is target0"); + assert_equals(touch1.identifier, 42, "touch.identifier is requested value"); + assert_equals(touch1.pageX, 15, "touch.pageX is requested value"); + assert_equals(touch1.pageY, 20, "touch.pageY is requested value"); + check_touch_clientXY(touch1); + assert_equals(touch1.screenX, 35, "touch.screenX is requested value"); + assert_equals(touch1.screenY, 40, "touch.screenY is requested value"); + }, "document.createTouch exists and creates a Touch object with requested properties"); - touch2 = document.createTouch(window, target0, 44, 25, 30, 45, 50); + touch2 = document.createTouch(window, target0, 44, 25, 30, 45, 50); - var touchList; + var touchList; - test(function() { - touchList = document.createTouchList(); - assert_equals(touchList.length, 0, "touchList.length is 0"); - }, "document.createTouchList exists and correctly creates a TouchList from zero Touch objects"); + test(function() { + touchList = document.createTouchList(); + assert_equals(touchList.length, 0, "touchList.length is 0"); + }, "document.createTouchList exists and correctly creates a TouchList from zero Touch objects"); - if (touchList) - check_TouchList_object(touchList); + if (touchList) + check_TouchList_object(touchList); - test(function() { - touchList = document.createTouchList(touch1); - assert_equals(touchList.length, 1, "touchList.length is 1"); - assert_equals(touchList.item(0), touch1, "touchList.item(0) is input touch1"); - }, "document.createTouchList exists and correctly creates a TouchList from a single Touch"); + test(function() { + touchList = document.createTouchList(touch1); + assert_equals(touchList.length, 1, "touchList.length is 1"); + assert_equals(touchList.item(0), touch1, "touchList.item(0) is input touch1"); + }, "document.createTouchList exists and correctly creates a TouchList from a single Touch"); - if (touchList) - check_TouchList_object(touchList); + if (touchList) + check_TouchList_object(touchList); - test(function() { - touchList = document.createTouchList(touch1, touch2); - assert_equals(touchList.length, 2, "touchList.length is 2"); - assert_equals(touchList.item(0), touch1, "touchList.item(0) is input touch1"); - assert_equals(touchList.item(1), touch2, "touchList.item(1) is input touch2"); - }, "document.createTouchList exists and correctly creates a TouchList from two Touch objects"); + test(function() { + touchList = document.createTouchList(touch1, touch2); + assert_equals(touchList.length, 2, "touchList.length is 2"); + assert_equals(touchList.item(0), touch1, "touchList.item(0) is input touch1"); + assert_equals(touchList.item(1), touch2, "touchList.item(1) is input touch2"); + }, "document.createTouchList exists and correctly creates a TouchList from two Touch objects"); - if (touchList) - check_TouchList_object(touchList); + if (touchList) + check_TouchList_object(touchList); - target0.innerHTML = "Test complete." - done(); - } + target0.innerHTML = "Test complete." + done(); + } </script> <style> - div { - margin: 0em; - padding: 2em; - } + div { + margin: 0em; + padding: 2em; + } #target0 { - background: yellow; - border: 1px solid orange; + background: yellow; + border: 1px solid orange; } </style> </head> <body onload="run()"> - <h1>Touch Events: createTouch and createTouchList tests</h1> - <div id="target0">Please wait for test to complete...</div> - <div id="log"></div> + <h1>Touch Events: createTouch and createTouchList tests</h1> + <div id="target0">Please wait for test to complete...</div> + <div id="log"></div> </body> </html>